package cc.vicp.djx314.starfood.web.personnel.order;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cc.vicp.djx314.starfood.service.order.OrderService;

@Controller
public class CancleOrderController {
	public static final Logger logger = LoggerFactory.getLogger(CancleOrderController.class);

	@Autowired
	OrderService orderService;

	@RequestMapping(value = "/personnel/cancled/{id}", method = RequestMethod.PUT)
	public ModelAndView cancleOrder(@PathVariable("id") Integer orderId) {
		boolean isSuccess = false;
		try {
			orderService.updateOrderCancled(orderId);
			isSuccess = true;
		} catch (Exception e) {
			logger.info("作废订单出错", e);
		}
		ModelAndView model = new ModelAndView("jsontournamenttemplate");
		model.addObject("success", isSuccess);
		return model;
	}
}